core: Support named pipes
authorColin Walters <walters@verbum.org>
Wed, 9 Nov 2011 14:08:58 +0000 (09:08 -0500)
committerColin Walters <walters@verbum.org>
Wed, 9 Nov 2011 14:08:58 +0000 (09:08 -0500)
This is mainly useful for sysvinit's "/dev/initctl".

libostree/ostree-core.c
libostree/ostree-repo-file.c
tests/libtest.sh

index d65636c7d5201bf9d6ccb25e01bbbd1105905628..9b5b80148baca258c6c4fd73212e9f7ae2329ecb 100644 (file)
@@ -259,11 +259,15 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
       device_id = g_strdup_printf ("%u", (guint)stbuf.st_rdev);
       g_checksum_update (content_sha256, (guint8*)device_id, strlen (device_id));
     }
+  else if (S_ISFIFO(stbuf.st_mode))
+    {
+      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+    }
   else
     {
       g_set_error (error, G_IO_ERROR,
                    G_IO_ERROR_FAILED,
-                   "Unsupported file '%s' (must be regular, symbolic link, or device)",
+                   "Unsupported file '%s' (must be regular, symbolic link, fifo, or character/block device)",
                    path);
       goto out;
     }
@@ -477,6 +481,10 @@ ostree_pack_object (GOutputStream     *output,
           device = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_DEVICE);
           object_size = 4;
         }
+      else if (S_ISFIFO (mode))
+        {
+          object_size = 0;
+        }
       else
         g_assert_not_reached ();
 
@@ -525,6 +533,9 @@ ostree_pack_object (GOutputStream     *output,
             goto out;
           g_assert (bytes_written == 4);
         }
+      else if (S_ISFIFO (mode))
+        {
+        }
       else
         g_assert_not_reached ();
     }
@@ -774,6 +785,14 @@ unpack_file (const char   *path,
           goto out;
         }
     }
+  else if (S_ISFIFO (mode))
+    {
+      if (mkfifo (dest_path, mode) < 0)
+        {
+          ot_util_set_error_from_errno (error, errno);
+          goto out;
+        }
+    }
   else
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
index 66268723d1d62e3f160642498b5cf05eb64ca1cb..6d5162e56b9d56219212bab029e55480a848b169 100644 (file)
@@ -827,7 +827,7 @@ query_child_info_file_archive (OstreeRepo       *repo,
     file_type = G_FILE_TYPE_SYMBOLIC_LINK;
   else if (S_ISREG (mode))
     file_type = G_FILE_TYPE_REGULAR;
-  else if (S_ISBLK (mode) || S_ISCHR(mode))
+  else if (S_ISBLK (mode) || S_ISCHR(mode) || S_ISFIFO(mode))
     file_type = G_FILE_TYPE_SPECIAL;
   else
     {
index 8ebedf7c5b889b377815a50e76016ff024d08b75..4e3795a3bac701051245dd108622ade56db76a30 100644 (file)
@@ -90,6 +90,7 @@ setup_test_repository () {
     $OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first"
 
     mkdir baz
+    mkfifo baz/afifo  # named pipe
     echo moo > baz/cow
     echo alien > baz/saucer
     mkdir baz/deeper